<?php

namespace app\model\questionnaire;

use app\BaseModel;
use app\model\UserModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

/**
 * 问卷-任务
 */
class QuestionnaireTaskModel extends BaseModel
{
    protected $name = 'questionnaire_task';

    /**
     * 发布人
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(UserModel::class,'uid')->bind([
            'user_name' => 'name',
            'role_name'
        ]);
    }

    /**
     * 任务问卷
     * @return HasMany
     */
    public function TaskPaper(): HasMany
    {
        return $this->hasMany(QuestionnaireTaskPaperModel::class,'task_id');
    }

    /**
     * 任务用户
     * @return HasMany
     */
    public function TaskUser(): HasMany
    {
        return $this->hasMany(QuestionnaireTaskUserModel::class,'task_id');
    }
}